using System;
using System.Collections.Generic;
using System.Text;

namespace GraphAlgsPresentation.ScriptLibrary
{
    /// <summary>
    /// Provides a insert text command
    /// </summary>
    [Serializable]
    public class InsertText : Command
    {
        private string _text;

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertText"/> class.
        /// </summary>
        public InsertText()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InsertText"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        public InsertText(string text)
        {
            this.Text = text;
        }

        /// <summary>
        /// Runs this instance.
        /// </summary>
        public override void Run()
        {
            this.Context.CommentControl.Insert(this.Text);
        }

        /// <summary>
        /// Undoes this instance.
        /// </summary>
        public override void Undo()
        {
            this.Context.CommentControl.Lines.RemoveAt(this.Context.CommentControl.Lines.Count - 1);
        }
    }
}
